//
//  YGTableViewCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/28.
//

#import "YGBodyHistoryTableViewCell.h"
#import "YGBodyHistoryModel.h"
@implementation YGBodyHistoryTableViewCell

- (void)setData:(id)data{
    
    [super setData:data];   //此处一定要调用父类
 
    for (int i = 0; i <self.confi.row; i++) {
        UILabel *label =  [self viewWithTag:labelTag + i];
        NSString *content;
        if (self.tag == 0) {
            //头部是字符串
            content = [data objectAtIndex:i];
            label.font = [UIFont boldSystemFontOfSize:13];
        }else{
            YGBodyHistoryModel *model = (YGBodyHistoryModel *)data;
            switch (i) {
                case 0:
                {
                    content = model.weight;
                }
                    break;
                case 1:
                {
                    content = model.bmr;
                }
                    break;
                case 2:
                {
                    content = model.bmi;
                }
                    break;
                    
                case 3:
                {
                    content = [self time_timestampToString:model.selfTestTime];
                }
                    break;
                    
                default:
                    break;
            }
        }

        label.text = content;
    }
    
}

- (NSString *)time_timestampToString:(NSInteger)timestamp{

    timestamp = timestamp/1000.0;
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp];

    NSDateFormatter *dateFormat=[[NSDateFormatter alloc]init];

     [dateFormat setDateFormat:@"yyyy-MM-dd"];

    NSString* string=[dateFormat stringFromDate:confromTimesp];

    return string;

}
@end
